'''
Created on Jun 6, 2012

@author: thomas_dao
'''

from google.appengine.ext import ndb
from entity.entity import Post

  
def get_by_author(author_key, **q_options):
    qry = Post.query(Post.author == author_key).order(-Post.created_time)
    data = yield qry.fetch_async(20, **q_options)
    raise ndb.Return(data)

@ndb.tasklet
def get_by_event(event_key, limit=10, **q_options):
    qry = Post.query(Post.event == event_key).order(-Post.created_time)
    post_list = yield qry.fetch_async(limit=limit, **q_options)
    raise ndb.Return(post_list)